
package com.shop.cereshop.admin.service.userAuth.impl;

import cn.hutool.core.util.DesensitizedUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.shop.cereshop.admin.dao.userAuth.UserRealnameAuthDAO;
import com.shop.cereshop.commons.domain.userAuth.UserRealnameAuth;
import com.shop.cereshop.admin.service.userAuth.UserRealnameAuthService;

import com.shop.cereshop.commons.domain.userAuth.UserRealnameAuthRespond;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 业务实现类
 * 用户实名认证表
 * </p>
 *
 * @author 
 * @date 2025-08-07
 */
@Slf4j
@Service
public class UserRealnameAuthServiceImpl implements UserRealnameAuthService {
    @Resource
    private UserRealnameAuthDAO userRealnameAuthDAO;

    @Override
    public UserRealnameAuthRespond findAuthInfoByUserId(Long buyerUserId) {
        UserRealnameAuth userId = userRealnameAuthDAO.selectOne(new QueryWrapper<UserRealnameAuth>().eq("user_id", buyerUserId));
        if (userId == null) {
            return null;
        }
        return UserRealnameAuthRespond.builder()
                .userId(userId.getUserId())
                .realName(DesensitizedUtil.chineseName(userId.getRealName()))
                .idCardNumber(DesensitizedUtil.idCardNum(userId.getIdCardNumber(), 6, 4))
                .idCardType(userId.getIdCardType())
                .idCardHandheld(userId.getIdCardHandheld())
                .build();
    }

    @Override
    public Integer updateStatue(Integer statue, Long userId) {
        return userRealnameAuthDAO.updateStatue(statue,userId);
    }
}
